<template>
  <div class="page_main">
    <div class="left">
      <Manager class="manager"></Manager>
      <div class="global-button">
        <button @click="handleDown">打印简历</button>
        <button style="background-color:aquamarine;" @click="switchTempalte">切换模板</button>
      </div>
    </div>

    <hr class="hr-double-arrow">
    <div class="right">
      <router-view class="template"></router-view>
    </div>

  </div>

</template>

<script setup lang="ts">
import Manager from './components/manager/manager.vue'
import { useRouter } from 'vue-router';
import {downloadPDF} from './utils/pdfUtils';
import { useStore } from './store/store'
const store = useStore()

const router = useRouter();
function handleDown() {
  //导出PDF
  downloadPDF(document.querySelector('.template'), '我的PDF');
}

function switchTempalte() {
  //切换模板
  const template_all = store.template_all;
  // 随机取一个模板
  let index = Math.floor(Math.random() * template_all.length);
  const template = template_all[index];
  router.push({ name: template });
}
</script>

<style scoped lang="scss">
@import url('./style/mycss/main.scss');
</style>
